<?php /*a:3:{s:46:"D:\myweb\lemocms\view\admin\article\index.html";i:1569490772;s:46:"D:\myweb\lemocms\view\admin\common\header.html";i:1569314347;s:46:"D:\myweb\lemocms\view\admin\common\footer.html";i:1569314347;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo config('admin.sys_name'); ?>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/main.css?v=<?php echo time(); ?>" media="all">
    <link rel="stylesheet" href="/static/plugins/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style id="LM-bg-color">
    </style>
</head>
<div class="LM-container">
    <div class="LM-main">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>文章<?php echo lang('list'); ?></legend>
            <blockquote class="layui-elem-quote">
                <div class="LM-table">

                    <div class="layui-inline">
                            <input type="text" id='keys' name="keys" lay-verify="required" placeholder="<?php echo lang('pleaseEnter'); ?>" autocomplete="off" class="layui-input">

                    </div>
                    <button class="layui-btn data-add-btn layui-btn-sm" lay-submit="" lay-filter="add" id="search"><?php echo lang('search'); ?></button>
                    <a href="<?php echo url('add'); ?>"  class="layui-btn layui-btn-sm layui-btn-warm"><?php echo lang('add'); ?>文章</a>

                </div>
              </blockquote>

        </fieldset>



        <table class="layui-table" id="list" lay-filter="list"></table>
    </div>
</div>


<script type="text/html" id="action">
    <a href="<?php echo url('edit'); ?>?id={{d.id}}" class="layui-btn  layui-btn-xs" lay-event="edit"><?php echo lang('edit'); ?></a>
    <a  class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><?php echo lang('del'); ?></a>
</script>
<!-- <script type="text/html" id="status">
    <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
</script> -->

<script type="text/html" id="thumb">
    <!-- {{d.title}}<img src="{{d.thumb}}" onmouseover="layer.tips('<img src={{d.thumb}}>',this,{tips: [1, '#fff']});" onmouseout="layer.closeAll();"> -->
    <img src="{{d.thumb}}" onmouseover="layer.tips('<img src={{d.thumb}}>',this,{tips: [1, '#fff']});" onmouseout="layer.closeAll();">
</script>
<script type="text/html" id="start_time">
    {{layui.util.toDateString(d.start_time*1000, 'yyyy/MM/dd HH:mm:ss')}}
</script>

<script type="text/html" id="post_time">
    {{layui.util.toDateString(d.post_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<!-- <script type="text/html" id="create_time">
    {{layui.util.toDateString(d.create_time*1000, 'yyyy/MM/dd HH:mm:ss')}}
</script> -->
<script type="text/html" id="update_time">
   {{layui.util.toDateString(d.update_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>

<script src="/static/plugins/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        var tableIn = table.render({
            elem: '#list',
            //url: '<?php echo url("index"); ?>',
            url: '<?php echo url("index.php/api/v1.api/getContentList"); ?>',
            method: 'post',
            data: {
                page: "{<?php echo htmlentities($page); ?>}",
                limit: "{<?php echo htmlentities($limit); ?>}",
            },
            cols: [[
                {checkbox: true, fixed: true},
                {field: 'id', title: 'ID', width: 60, fixed: true, sort: true},
                {field: 'category_id', title: '分类名称', width: 120, fixed: true, align: 'center', templet:"cate_name"},
                {field: 'title', title: '标题', width: 250, align: 'center'},
                {field: 'description', title: '关键词', width: 400, align: 'center'},
                {field: 'thumb', title: '缩略图', width: 180, templet:'#thumb', align: 'center'},
                {field: 'hit_count', title: '点击量', width: 80, align: 'center'},
                // {field: 'status', title: '状态', width: 90, templet:'#status'},
                {field: 'post_time', title: '发布时间', width: 160, templet:'#post_time',align: 'center'},
                // {field: 'update_time', title: '添加时间', width: 180,templet:'#create_time'},
                {field: 'update_time', title: '修改时间', width: 160,templet:'#update_time', align: 'center'},
                {title:'操作',width:100, toolbar: '#action',align:"center"}

            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            done: function(res, page, count){
                //分类显示中文名称
                $("[data-field='category_id']").children().each(function(){
                    if($(this).text() == '0'){
                        $(this).text("全部")
                    }else if($(this).text() == '1'){
                        $(this).text("法律法规")
                    }
                    else if($(this).text() == '2'){
                        $(this).text("新闻资讯")
                    }
                    else if($(this).text() == '3'){
                        $(this).text("宣传资料")
                    }
                    else if($(this).text() == '4'){
                        $(this).text("经验分享")
                    }
                    else if($(this).text() == '5'){
                        $(this).text("星期三查餐厅")
                    }
                    else if($(this).text() == '6'){
                        $(this).text("创建食品安全示范城市")
                    }
                    else if($(this).text() == '7'){
                        $(this).text("食品安全风险系列知识专题")
                    }
                    else if($(this).text() == '8'){
                        $(this).text("名师课堂专题")
                    }
                    else if($(this).text() == '9'){
                        $(this).text("各专题内容")
                    }
                    else if($(this).text() == '10'){
                        $(this).text("每日健康")
                    }
                    else if($(this).text() == '11'){
                        $(this).text("监管动态")
                    }
                    else if($(this).text() == '12'){
                        $(this).text("最新通知")
                    }
                    else if($(this).text() == '13'){
                        $(this).text("国内食安")
                    }
                    else if($(this).text() == '14'){
                        $(this).text("国际食安")
                    }
                    else if($(this).text() == '15'){
                        $(this).text("国家法律")
                    }
                    else if($(this).text() == '16'){
                        $(this).text("食品安全风险预警")
                    }
                    else if($(this).text() == '17'){
                        $(this).text("深圳食安")
                    }
                    else if($(this).text() == '18'){
                        $(this).text("国家行政法规")
                    }
                    else if($(this).text() == '19'){
                        $(this).text("国家规章")
                    }
                    else if($(this).text() == '21'){
                        $(this).text("国家法规性文件")
                    }
                    else if($(this).text() == '22'){
                        $(this).text("广东省法规")
                    }
                    else if($(this).text() == '24'){
                        $(this).text("食品抽检与复检工作指引")
                    }
                    else if($(this).text() == '25'){
                        $(this).text("生态食安大鹏行")
                    }
                    else if($(this).text() == '26'){
                        $(this).text("食安误区")
                    }
                    else if($(this).text() == '27'){
                        $(this).text("食安生活")
                    }
                    else if($(this).text() == '28'){
                        $(this).text("食安谣言")
                    }
                    else if($(this).text() == '29'){
                        $(this).text("活动回顾")
                    }
                    else if($(this).text() == '30'){
                        $(this).text("曝光台")
                    }
                    else if($(this).text() == '31'){
                        $(this).text("食安知识科普")
                    }
                    else if($(this).text() == '32'){
                        $(this).text("广东省规范性文件")
                    }
                    else if($(this).text() == '33'){
                        $(this).text("深圳市法规")
                    }
                    else if($(this).text() == '34'){
                        $(this).text("深圳市规范性文件")
                    }
                    

                })
            }
        });



        table.on('tool(list)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('<?php echo lang("Are you sure you want to delete it"); ?>', function(index){
                    loading =layer.load(1, {shade: [0.1,'#fff']});
                    $.post("<?php echo url('delete'); ?>",{id:data.id},function(res){
                        layer.close(loading);
                        layer.close(index);
                        if(res.code>0){
                            layer.msg(res.msg,{time:1000,icon:1});
                            obj.del();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                });
            }

        });

        form.on('switch(status)', function(data){
                loading =layer.load(1, {shade: [0.1,'#fff']});
                var status = $(this).attr('checked')?0:1;
                $.post("<?php echo url('state'); ?>",{id:data.value,status:status},function(res){
                    layer.close(loading);
                    if(res.code>0){
                        layer.msg(res.msg,{time:1000,icon:1});
                    }else{
                        layer.msg(res.msg,{time:1000,icon:2});
                    }
                });
        });

        $('#search').click(function () {
            var $keys = $('#keys').val();
            if(!$keys){
                return layer.msg('请输入关键词');
            }

            tableIn.reload({ page: {page: 1},where: {keys: $keys}});

        })


    });


</script>